function gt3(i: Ptr[Int]) {
    return *i > 3;
}

function main() {
    var v: Vector[Int] = Vector.new(4);
    printf("length = %zu\n", v.length);
    printf("capacity = %zu\n", v.data.length);

    v.push(1);
    printf("length = %zu\n", v.length);
    printf("capacity = %zu\n", v.data.length);
    printf(if v.pop().isSome() then "some\n" else "none\n");
    printf("length = %zu\n", v.length);
    printf("capacity = %zu\n", v.data.length);
    printf(if v.pop().isSome() then "some\n" else "none\n");
    printf("length = %zu\n", v.length);
    printf("capacity = %zu\n", v.data.length);

    v.push(11);
    v.push(22);
    v.push(33);
    v.push(44);
    printf("length = %zu\n", v.length);
    printf("capacity = %zu\n", v.data.length);

    for i in v {
        printf("iterate: %i\n", i);
    }

    v.push(55);
    printf("length = %zu\n", v.length);
    printf("capacity = %zu\n", v.data.length);

    v.push(66);
    v.push(77);
    printf("length = %zu\n", v.length);
    printf("capacity = %zu\n", v.data.length);

    for i in v {
        printf("iterate: %i\n", i);
    }

    v.pop();
    v.pop();
    v.pop();

    printf("length = %zu\n", v.length);
    printf("capacity = %zu\n", v.data.length);

    for i in v {
        printf("iterate: %i\n", i);
    }

    printf("length = %zu\n", v.length);
    v.clear();
    printf("length after clear = %zu\n", v.length);

    v.free();

    var v2: Vector[Int] = Vector.new();

    {
        var v1: Vector[Int] = Vector.new(3);
        v1.push(1);
        v1.push(3);
        v1.push(5);

        var v2: Vector[Int] = Vector.new(3);
        v2.push(5);
        v2.push(6);
        v2.push(7);

        var v3: Vector[Int] = Vector.new(3);
        v3.push(0);
        v3.push(1);
        v3.push(2);

        for v in [v1, v2, v3] {
            puts(if v.any(gt3) then "any = true" else "any = false");
            puts(if v.all(gt3) then "all = true" else "all = false");
        }
    }
}
